package com.anti.modular.bus.buscostbilldeposit.controller;

import com.anti.commom.annotation.BusinessLog;
import com.anti.commom.annotation.Permission;
import com.anti.commom.enums.LogAnnotionOpTypeEnum;
import com.anti.commom.api.Result;
import com.anti.jdbc.support.page.PageParam;
import com.anti.modular.bus.buscostbilldeposit.param.BusCostBillDepositParam;
import com.anti.modular.bus.buscostbilldeposit.service.BusCostBillDepositService;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;

/**
 * 費用類別控制器
 *
 * @author anti
 * @date 2021-04-08 09:51:49
 */
@RestController
@RequestMapping("busCostBillDeposit")
public class BusCostBillDepositController {

    @Resource
    private BusCostBillDepositService busCostBillDepositService;

    /**
     * 查询費用類別
     *
     * @author anti
     * @date 2021-04-08 09:51:49
     */
    @GetMapping("page")
    public Result page(PageParam pageParam, BusCostBillDepositParam busCostBillDepositParam) {
        return Result.data(busCostBillDepositService.page(pageParam,busCostBillDepositParam));
    }

    /**
     * 添加費用類別
     *
     * @author anti
     * @date 2021-04-08 09:51:49
     */
    @Permission
    @PostMapping("add")
    @BusinessLog(title = "費用類別_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public Result add(@RequestBody @Validated(BusCostBillDepositParam.add.class) BusCostBillDepositParam busCostBillDepositParam) {
            busCostBillDepositService.add(busCostBillDepositParam);
        return Result.success("新增成功");
    }

    /**
     * 删除費用類別
     *
     * @author anti
     * @date 2021-04-08 09:51:49
     */
    @Permission
    @PostMapping("delete")
    @BusinessLog(title = "費用類別_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public Result delete(@RequestBody @Validated(BusCostBillDepositParam.delete.class) BusCostBillDepositParam busCostBillDepositParam) {
            busCostBillDepositService.delete(busCostBillDepositParam);
        return Result.success("删除成功");
    }

    /**
     * 编辑費用類別
     *
     * @author anti
     * @date 2021-04-08 09:51:49
     */
    @Permission
    @PostMapping("edit")
    @BusinessLog(title = "費用類別_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public Result edit(@RequestBody @Validated(BusCostBillDepositParam.edit.class) BusCostBillDepositParam busCostBillDepositParam) {
            busCostBillDepositService.edit(busCostBillDepositParam);
        return Result.success("修改成功");
    }

    /**
     * 查看費用類別
     *
     * @author anti
     * @date 2021-04-08 09:51:49
     */
    @GetMapping("detail")
    public Result detail(@Validated(BusCostBillDepositParam.detail.class) BusCostBillDepositParam busCostBillDepositParam) {
        return Result.data(busCostBillDepositService.detail(busCostBillDepositParam));
    }

    /**
     * 費用類別列表
     *
     * @author anti
     * @date 2021-04-08 09:51:49
     */
    @GetMapping("list")
    public Result list(BusCostBillDepositParam busCostBillDepositParam) {
        return Result.data(busCostBillDepositService.list(busCostBillDepositParam));
    }

}
